package com.lp.config;

import lombok.Data;

import java.io.Serializable;

@Data
public class AppReturn implements Serializable {

    private Integer code;
    private String msg;
    private Object data;

    public static AppReturn success(CodeMsg codeMsg, Object data) {
        AppReturn appReturn = new AppReturn();
        appReturn.setCode(codeMsg.getCode());
        appReturn.setMsg(codeMsg.getMsg());
        appReturn.setData(data);
        return appReturn;
    }

    public static AppReturn success(String msg, Object data) {
        AppReturn appReturn = new AppReturn();
        appReturn.setCode(CodeMsg.SUCCESS.getCode());
        appReturn.setMsg(msg);
        appReturn.setData(data);
        return appReturn;
    }

    public static AppReturn success(Object data) {
        AppReturn appReturn = new AppReturn();
        appReturn.setCode(CodeMsg.SUCCESS.getCode());
        appReturn.setMsg(CodeMsg.SUCCESS.getMsg());
        appReturn.setData(data);
        return appReturn;
    }

    public static AppReturn fail(CodeMsg codeMsg, Object data) {
        AppReturn appReturn = new AppReturn();
        appReturn.setCode(codeMsg.getCode());
        appReturn.setMsg(codeMsg.getMsg());
        appReturn.setData(data);
        return appReturn;
    }

    public static AppReturn fail(String msg, Object data) {
        AppReturn appReturn = new AppReturn();
        appReturn.setCode(CodeMsg.FAIL.getCode());
        appReturn.setMsg(msg);
        appReturn.setData(data);
        return appReturn;
    }

    public static AppReturn fail(CodeMsg codeMsg) {
        AppReturn appReturn = new AppReturn();
        appReturn.setCode(CodeMsg.FAIL.getCode());
        appReturn.setMsg(CodeMsg.FAIL.getMsg());
        return appReturn;
    }

    public static AppReturn fail(Object data) {
        AppReturn appReturn = new AppReturn();
        appReturn.setCode(CodeMsg.FAIL.getCode());
        appReturn.setMsg(CodeMsg.FAIL.getMsg());
        appReturn.setData(data);
        return appReturn;
    }
}
